<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
    </style>
</head>
<body>
<div id="app">
    <button @click="searchKey">搜索</button>
    <div v-for="result in results">
        <span>{{result.name}}</span>
        <span>{{result.price}}</span>
        <span>{{result.img}}</span>
        <span>{{result.shopnum}}</span>
        <hr/>
    </div>
</div>
</body>
<!--js文件cdn-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    var app = new Vue({
            el: "#app",
            data: {
                "keyword": "java",
                "results": [],
            },
            methods: {
                searchKey() {
                    var keyword = this.keyword;
                    console.log(keyword);
                    axios.get('search/' + keyword + '/0/20').then(response => {
                        console.log(response);
                        this.results = response.data;
                    })
                }
            }
        })
    ;
</script>
</html>
<!--
axios:网络通信
    第一步：请求数据，并将数据参数到data
    第二步：将数据取出显示
-->
